package com.itheima.mq;

import com.itheima.redis.RedisUtil;
import com.itheima.utils.SMSUtil;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * company: www.abc.com
 * Author: 29746
 * Create Data: 2020/11/18
 */
@Component
public class SmsCodeConsumer {

    @RabbitListener(queues = "sms_queue")
    public void reciver(String telephone){
        String code=SMSUtil.sendSmsValidCode(telephone);
        //String code= SMSUtil.generatorCode(4);
        RedisUtil.set("sms:code:"+telephone,code,5L, TimeUnit.MINUTES);
    }
}
